package spring.core.examples.xml;

/**
 * Demonstrates a been that uses constructor based dependency injection. A bean
 * like this will be fully functional after calling the constructor with all the
 * required parameters. This is possible, but it is not the preferred way to do
 * it.<br/>
 * <br/>
 * Also demonstrates object creation using a factory method.
 * 
 * @see AutowiredCouple
 * @see ResourcedCouple
 */
public class Couple {

	/**
	 * A factory method that created a new couple. Provides an alternative way
	 * to create a couple.
	 * 
	 * @param spouseA
	 *            the spouse a
	 * @param spouseB
	 *            the spouse b
	 * @return the couple
	 */
	public static Couple createCouple(Person spouseA, Person spouseB) {
		return new Couple(spouseA, spouseB);
	}

	/** The spouse a. */
	private Person spouseA;

	/** The spouse b. */
	private Person spouseB;

	/**
	 * Instantiates a new couple.
	 * 
	 * @param spouseA
	 *            the spouse a
	 * @param spouseB
	 *            the spouse b
	 */
	public Couple(Person spouseA, Person spouseB) {
		super();
		this.setSpouseA(spouseA);
		this.setSpouseB(spouseB);
	}

	/**
	 * Gets the spouse a.
	 * 
	 * @return the spouse a
	 */
	public Person getSpouseA() {
		return spouseA;
	}

	/**
	 * Gets the spouse b.
	 * 
	 * @return the spouse b
	 */
	public Person getSpouseB() {
		return spouseB;
	}

	/**
	 * Sets the spouse a.
	 * 
	 * @param spouseA
	 *            the new spouse a
	 */
	public void setSpouseA(Person spouseA) {
		this.spouseA = spouseA;
	}

	/**
	 * Sets the spouse b.
	 * 
	 * @param spouseB
	 *            the new spouse b
	 */
	public void setSpouseB(Person spouseB) {
		this.spouseB = spouseB;
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return this.getClass().getSimpleName() + " (" + this.getSpouseA()
				+ ", " + this.getSpouseB() + ")";
	}

}
